<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="student.name"/>
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            message:'hello',
            student:{
                name:'zhangsan',
                age:18
            }
        }
        /*
        第一种侦听器的写法
        
        watch:{
            message:function(newvalue,oldvalue){
                console.log(newvalue,oldvalue);
            } 
        }
        */
    });
    //第2种侦听器的写法
    vm.$watch('student',function(newvalue,oldvalue){
        console.log(newvalue,oldvalue);
    },{deep:true,immediate:true})
</script>